#include "bullet.h"

bullet::bullet() {
    //加载子弹
    m_bullet.load(BULLET_MY_PATH);
    //子弹坐标
    m_X=GAME_WIDTH*0.5-m_bullet.width()*0.5;
    m_Y=GAME_HEIGHT;
    //子弹状态
    m_Free=true;
    //子弹速度
    m_speed=BULLET_MY_SPEED;
    //子弹框架
    m_Rect.setWidth(m_bullet.width());
    m_Rect.setHeight(m_bullet.height());
    m_Rect.moveTo(m_X,m_Y);
}

void bullet::updatePosition()
{
    //判断子弹是否空闲
    if(m_Free){
        return ;
    }
    //子弹移动
    m_Y-=m_speed;
    m_Rect.moveTo(m_X,m_Y)       ;
    if(m_Y<=m_Rect.height()){
        m_Free=true;
    }
}
